package com.stockz.scanner.screen;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.core.util.ListUtil;
import com.stockz.scanner.screen.configuration.BullishClimaticVolumeScreenConfiguration;
import com.stockz.ui.swing.charting.display.indicator.Stochastics;
import com.stockz.ui.swing.charting.util.MathUtil;

public class BullishClimaticVolumeScreen implements Screen<BullishClimaticVolumeScreenConfiguration> {
	private final BullishClimaticVolumeScreenConfiguration configuration = new BullishClimaticVolumeScreenConfiguration();
	
	@Override
	public BullishClimaticVolumeScreenConfiguration getConfiguration() {
		return configuration;
	}
	
	@Override
	public int getMandatorySpan() {
		return configuration.getVolumeSmaSpan();
	}

	@Override
	public boolean isMatch(List<Bar> barList) {
		double volumeSma = MathUtil.avg(barList,BarValueType.VOLUME,0,configuration.getVolumeSmaSpan());
		double stochastics = Stochastics.value(ListUtil.convert(barList, BarValueType.AVGPRICE), configuration.getStochasticsSpan());
		return ((barList.get(0).getVolume() > (volumeSma*configuration.getVolumeSmaMinimumMultiple()))
				&& (stochastics < configuration.getStochasticsUpplerLimit()));
	}

}
